The largest Interview Solution Library on the web


« Previous | 1 | 2 | 3 | Next »
In Dojo, there are two ways.
1. A Dojo button's onclick attribute takes the name of the event handler method. You don't
actually call the method like you do for a regular DOM button.
2. Second, the event handler method gets only one parameter – the Event object.
Let's have a look at an example. The event handler is registered as follows:
<button dojoType="dijit.form.Button" onclick="showEvent">OK</button>

The event handler method looks like this:

function showEvent(theEvent)
{
alert("Event " + theEvent.type);
}

function showEvent(theEvent) {
alert("Event " + theEvent.type + " for element " + theEvent.target.nodeName);
}
Register event handlers for the buttons as shown below.
<button dojoType="dijit.form.Button" onclick="showEvent">OK</button>
<button dojoType="dijit.form.Button" onclick="showEvent">Cancel</button>
Write the handler method as shown in bold face below:
<script type="text/javascript">
dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.Button");
function showEvent(theEvent) {
alert("Event: " + theEvent.type +
" for element: " + theEvent.target.nodeName);
}

</script>
« Previous | 1 | 2 | 3 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com